<template>
  <div>
    <!-- 头部 --state-->
    <div class="nav">
      <p v-if="e==0">
        <span>.</span>
        订单计划查看
      </p>
      <p v-if="e==1">
        <span>.</span>
        订单计划详情
      </p>
      <div id="nav_go4">
        <el-button type="info" icon="el-icon-back" class="btn_fanhui" @click="revert()">返回</el-button>
      </div>
    </div>
    <div class="addplan_box">
      <div class="addplan_title">
        <ul>
          <li>
            <span>计划时间</span>
            <el-input style="width:60%" v-model="yearmonth" readonly></el-input>
          </li>
          <li>
            <span>编号</span>
            <el-input style="width:60%" v-model="no" readonly></el-input>
          </li>
        </ul>
      </div>
      <div id="addplan_table">
        <template>
          <el-table :data="tableData" style="width: 100%" height="631">
            <el-table-column type="index" label="序号" align="center"></el-table-column>
            <el-table-column label="主机厂" align="center">
              <template slot-scope="scope">
                <el-input v-model="scope.row.mainengine" readonly></el-input>
              </template>
            </el-table-column>
            <el-table-column label="产品图号" align="center">
              <template slot-scope="scope">
                <el-input v-model="scope.row.picno" readonly></el-input>
              </template>
            </el-table-column>
            <el-table-column label="产品名称" align="center">
              <template slot-scope="scope">
                <el-input v-model="scope.row.prcname" readonly></el-input>
              </template>
            </el-table-column>
            <el-table-column label="销量需求" align="center">
              <template slot-scope="scope">
                <el-input v-model="scope.row.saleask" readonly></el-input>
              </template>
            </el-table-column>
            <!-- ////////////////////////////////////////////// -->

            <el-table-column label="需求时间及数量" align="center">
              <el-table-column label="1" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[0]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="2" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[1]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="3" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[2]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="4" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[3]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="5" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[4]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="6" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[5]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="7" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[6]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="8" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[7]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="9" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[8]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="10" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[9]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="11" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[10]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="12" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[11]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="13" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[12]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="14" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[13]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="15" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[14]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="16" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[15]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="17" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[16]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="18" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[17]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="19" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[18]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="20" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[19]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="21" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[20]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="22" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[21]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="23" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[22]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="24" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[23]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="25" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[24]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="26" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[25]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="27" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[26]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="28" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[27]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="29" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[28]" readonly></el-input>
                </template>
              </el-table-column>
              <el-table-column label="30" align="center" width="46">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.lstnum[29]" readonly></el-input>
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="本月合计" align="center">
              <template slot-scope="scope">
                <el-input v-model="scope.row.total" readonly></el-input>
              </template>
            </el-table-column>
            <el-table-column label="备注" align="center">
              <template slot-scope="scope">
                <el-input v-model="scope.row.remark" readonly></el-input>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </div>
    </div>
    <div class="bottom" v-show="e==0">
      <el-button type="primary" size="medium" @click="pass()">通过</el-button>
      <el-button type="info" size="medium" @click="revert()">返回</el-button>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      empno:"",
      planno: "",
      e: "",
      active: 1,
      tableData: [],
      a: true,
      yearmonth: "", //年月
      no: "" //编号
    };
  },
  created() {
        this.empno =JSON.parse(localStorage.getItem('empno'))
    this.planno = this.$route.query.planno;
    this.e = this.$route.query.e;
    this.getval();
  },
  methods: {
    //返回
    revert() {
      this.$router.go(-1);
    },
    //通过驳回
    pass() {
   var obj = 
   {
     planno:this.planno,
   empno:this.empno
   }
      ;
      var objs = JSON.stringify(obj);
      axios(
        "/apis/PurchasingManagement.asmx/Save_Purchase?index=5&jsondata=" + objs
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
     if (datas.string.__text == "SUCCESS") {
            this.$message.success("查看成功");
            window.history.go(-1);
          } else {
            this.$message.error(datas.string.__text);
          }
      });
    },
    //详情数据
    getval() {
      let arr = { id: 1, planno: this.planno };
      let arr1 = JSON.stringify(arr);
      axios(
        "apis/SalesManagement.asmx/OrderPlanlst?index=2&jsondata=" + arr1
      ).then(({ data }) => {
        let data1 = this.$x2js.xml2js(data);
        let data3 = JSON.parse(data1.string.__text);
        console.log(data3);
        this.no = data3.planno;
        this.yearmonth = data3.year + "-" + data3.month;
        var val = [];
        data3.lstplan.forEach(item => {
          val.push(item);
        });
        this.tableData = val;
      });
    },
    fn() {
      if (this.a == true) {
        this.a = false;
      } else {
        this.a = true;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
@import "@/assets/scss/base.scss";
.nav {
  //border: solid 1px red;
  height: 60px;
  padding: 0 1%;
  position: relative;
  p {
    height: 40px;
    margin: 10px 0;
    line-height: 40px;
    span {
      background: $Header_color;
      color: $Header_color;
    }
  }
  #nav_go4 {
    position: absolute;
    top: 10px;
    right: 1%;
    img {
      height: 16px;
      padding-right: 10px;
    }
  }
}
.ebtn {
  margin-right: 20px;
}
.addplan_box {
  background: $white;
  width: 98%;
  padding: 0 1%;
  .addplan_title {
    ul {
      margin-top: 10px;
      overflow: hidden;
      li {
        float: left;
        height: 50px;
        line-height: 50px;
        font-size: 14px;
        margin-left: 1%;
        text-align: center;
      }
    }
  }
  #addplan_table {
    // margin-top: 10px;
  }
  .flow_path {
    padding-top: 30px;
  }
}
.bottom {
  margin-top: 10px;
  text-align: center;
}
</style>
<style>
#addplan_table .el-table th > .cell {
  text-align: center;
  padding: 0;
}
#addplan_table .el-input__inner {
  border: none;
  outline: none;
}
#addplan_table .el-table {
  font-size: 14px;
}
#addplan_table .el-table td,
.el-table th {
  padding: 0;
  height: 40px;
}
#addplan_table .el-table .cell {
  line-height: normal;
  padding: 0;
}
#addplan_table .el-table .cell,
.el-table--border td:first-child .cell,
.el-table--border th:first-child .cell {
  padding: 0;
}
</style>